/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jollylengkono.skripsi.KnowledgeBases.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jollylengkono.skripsi.dao.KnowledgeBasesDao;
import jollylengkono.skripsi.model.KnowledgeBases;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Nicholai
 */
public class KnowledgeBasesRead extends Action {
    private String FORWARD;

    public KnowledgeBasesRead() {
    }
    
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws Exception {
        long id = Long.parseLong(request.getParameter("kb_id"));
        KnowledgeBases kb = (KnowledgeBases) new KnowledgeBasesDao().read(id);
        if (kb==null) {
            this.FORWARD="fail";
        } else {
            this.FORWARD="success";
            request.setAttribute("knowledgeBase", kb);
        }
        return mapping.findForward(FORWARD);
    }
}
